home *** CD-ROM | disk | FTP | other *** search
/ Champak 62 / Volume 62 - JOGO DISK .iso / Games / penguin_dinner.swf / scripts / __Packages / classes / game / Table.as < prev   
Text File  |  2008-03-17  |  2KB  |  91 lines

  1. class classes.game.Table extends classes.ui.IconicButton
  2. {
  3.    var guests = [];
  4.    var earnings = 0;
  5.    function Table()
  6.    {
  7.       super();
  8.       this.stools.gotoAndStop("stool_" + String(classes.core.SOManager.getInstance().__get__upgradeStool()));
  9.       this.plate_0._visible = false;
  10.       this.plate_1._visible = false;
  11.       this.money._visible = false;
  12.       this.plate_0.stop();
  13.       this.plate_1.stop();
  14.       this.money.stop();
  15.    }
  16.    function onRelease()
  17.    {
  18.    }
  19.    function onPress()
  20.    {
  21.       if(this.locked)
  22.       {
  23.          return undefined;
  24.       }
  25.       classes.core.SoundManager.getInstance().startSound("click_game_object");
  26.       this.filters = [];
  27.       this.dispatchEvent(new classes.events.WidgetEvent(this,classes.ui.IconicButton.CLICK));
  28.    }
  29.    function showFood($guest)
  30.    {
  31.       var _loc2_ = 0;
  32.       while(_loc2_ < this.guests.length)
  33.       {
  34.          if(this.guests[_loc2_] == $guest)
  35.          {
  36.             this["plate_" + _loc2_]._visible = true;
  37.             this["plate_" + _loc2_].gotoAndStop($guest.food);
  38.          }
  39.          _loc2_ = _loc2_ + 1;
  40.       }
  41.    }
  42.    function setGuests($guests)
  43.    {
  44.       if($guests == undefined)
  45.       {
  46.          this.guests = [];
  47.       }
  48.       else
  49.       {
  50.          this.earnings = 0;
  51.          this.guests = $guests.slice();
  52.       }
  53.       this.guestsEating = this.guests.length;
  54.    }
  55.    function guestFinishedEating($guest, $guestWorstMood)
  56.    {
  57.       var _loc2_ = 0;
  58.       while(_loc2_ < this.guests.length)
  59.       {
  60.          if(this.guests[_loc2_] == $guest)
  61.          {
  62.             this["plate_" + _loc2_].gotoAndStop(classes.game.Food.TYPE_NONE);
  63.          }
  64.          _loc2_ = _loc2_ + 1;
  65.       }
  66.       this.earnings += classes.game.GameData.FOOD_PRICE($guestWorstMood);
  67.       this.showMoney($guestWorstMood);
  68.    }
  69.    function takeMoney()
  70.    {
  71.       this.money._visible = false;
  72.       this.plate_0._visible = false;
  73.       this.plate_1._visible = false;
  74.       this.attachMovie("cash_anim","cash_anim",1,{moneyStr:"$" + String(this.earnings),_x:0,_y:-20});
  75.       this.earnings = 0;
  76.    }
  77.    function showMoney($guestWorstMood)
  78.    {
  79.       this.guestsEating = this.guestsEating - 1;
  80.       if(this.guestsEating == 0 && this.earnings > 0)
  81.       {
  82.          this.money.gotoAndStop($guestWorstMood);
  83.          this.money._visible = true;
  84.       }
  85.    }
  86.    function isFree()
  87.    {
  88.       return this.guests.length == 0 && this.earnings == 0;
  89.    }
  90. }
  91.